package cc.eddic.examinationsystem.dto;

import cc.eddic.examinationsystem.domain.Exam;
import cc.eddic.examinationsystem.domain.ExamScore;
import cc.eddic.examinationsystem.domain.Student;
import lombok.*;
import org.springframework.beans.BeanUtils;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class ExamScoreModel {
    private Long id;
    private Integer score;
    private String studentName;
    private String examName;

    public static ExamScoreModel from(final ExamScore examScore){
        ExamScoreModel dto = new ExamScoreModel();
        BeanUtils.copyProperties(examScore, dto);
        dto.studentName = examScore.getStudent().getName();
        dto.examName = examScore.getExam().getName();
        return dto;
    }
}
